import { HelperTool } from "./Services/Common";

export class AppSetting {
    static Version = "2022.4.1.1";
    GuiScriptBaseUrl = "https://unpkg.com/";
    ViewerScriptBaseUrl = "https://unpkg.com/";
    ViewerDataBaseUrl = "https://www.aisanwei.cn/api/ViewData/";
    ViewerEnableGL2 = false;
    ViewerEnableGui = "0";
    ViewerElementId = 'viewer-element';
    StartSceneUrl = "";
    UseQuery() {
        let v = HelperTool.FromQuery();
        let ds = this as any as { [key: string]: string };
        for (let key of Object.keys(ds)) {
            if (v[key.toLowerCase()] != undefined) {
                ds[key] = v[key.toLowerCase()];
            }
        }
        return this;
    }
    Init() {
        return this.UseQuery();
    }
}
export class UserSetting {
    Save() {
        let ds = this as any as { [key: string]: string };
        for (let key of Object.keys(ds)) {
            window.localStorage.setItem(key, ds[key]);
        }
    }
    Load() {
        let ds = this as any as { [key: string]: string };
        for (let key of Object.keys(ds)) {
            let value = window.localStorage.getItem(key)
            if (value != null) {
                ds[key] = value;
            }
        }
        return this;
    }
}